package com.tuling.llmlangchain4j.config;

import com.tuling.llmlangchain4j.storememery.MemerryStorePersistent;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class ChatMemoryProviderConfig {
    @Autowired
    private MemerryStorePersistent memerryStorePersistent;



    //使用键值对生成
    @Bean
    public ChatMemoryProvider chatMemoryProvider(){
        return merryId ->  MessageWindowChatMemory.builder().maxMessages(10).id(merryId)
//                .chatMemoryStore(new InMemoryChatMemoryStore())
                .chatMemoryStore(memerryStorePersistent)
                .build();
    }


}
